<template>
  <div class="zzp" @mousewheel="scrollBe">
    <transition name="fadeIn" mode="out-in">
      <keep-alive>
        <component :is="componentList[0]"></component>
      </keep-alive>
    </transition>
    <!-- <me-Nav></me-Nav>
    <nav-resource></nav-resource> -->
  </div>
</template>

<script>
import meNav from "./index.vue";
import navResource from "../navigation/ack/ack.vue";
import mePdf from "../pdf/pdf.vue";
import { bounded } from "../../formatTime";
export default {
  components: {
    navResource,
    meNav,
    mePdf,
  },
  data() {
    return {
      currentComponent: meNav,
      ifRender: true,
      componentList: [meNav, navResource, mePdf],
    };
  },
  methods: {
    scrollBe(e) {
      if (this.ifRender) {
        if (this.isParentNode(e.target, document.querySelector(".nav-box"))) {
          return;
        }
        if (this.isParentNode(e.target, document.querySelector(".nav-go"))) {
          return;
        }
        if (this.isParentNode(e.target, document.querySelector(".pdf"))) {
          return;
        }
        this.ifRender = false;
        this.judgeWheel(e);
        setTimeout(() => {
          this.ifRender = true;
        }, 2000);
      }
    },
    isParentNode(node, parentNode) {
      let sonNode = node;
      let isFatherNode;
      if (!node) return false;
      if (!parentNode) return false;
      while (sonNode.parentNode) {
        if (sonNode === parentNode) {
          isFatherNode = true;
          break;
        } else if (!sonNode.parentNode) {
          isFatherNode = false;
          break;
        } else {
          sonNode = sonNode.parentNode;
        }
      }
      return isFatherNode;
    },
    judgeWheel(e) {
      if (e.wheelDelta < 0) {
        this.componentList.push(this.componentList.shift());
      } else {
        this.componentList.unshift(this.componentList.pop());
      }
    },
  },
};
</script>

<style lang="less" scoped>
@import url("../../css/comment/animate.css");
.zzp{
  width: 100vw;
  height: calc(100vh - 50px);
}
</style>